/******************************************************************************
	This file is a part of the Snapshot Bioinformatics Project

	Copyright (C) 2012-2013 Jarom Schow

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#include "SnapshotPrefsDlg.h"

#include <QtCore/QCoreApplication>

#include <QtWidgets/QCheckBox>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QPushButton>

#include "SnapshotUI.h"

/**
**/
SnapshotPrefsDlg::SnapshotPrefsDlg( SnapshotUI *parent ) : QDialog( parent ), m_ui( parent )
{
	setWindowTitle( tr( "%1 Preferences" ).arg( qApp->applicationName() ) );

	initLayout();
}

/**
**/
SnapshotPrefsDlg::~SnapshotPrefsDlg()
{
}

/**
**/
void SnapshotPrefsDlg::accept()
{
	m_ui->setIgnoreEmpty( m_ignoreEmptyBtn->isChecked() );
	m_ui->setIgnoreUnclassified( m_ignoreUnclassBtn->isChecked() );
	m_ui->setIgnoreEnvSamp( m_ignoreEnvSampBtn->isChecked() );

	QDialog::accept();
}

/**
**/
void SnapshotPrefsDlg::initLayout()
{
	int			row = 0;
	int			col = 0;
	QPushButton	*btn;
	QGridLayout	*layout = new QGridLayout;

	setLayout( layout );

	m_ignoreEmptyBtn = new QCheckBox( tr( "Ignore taxa with no sequence data" ), this );
	layout->addWidget( m_ignoreEmptyBtn, row++, col, 1, 3 );
	m_ignoreEmptyBtn->setChecked( m_ui->getIgnoreEmpty() );

	m_ignoreUnclassBtn = new QCheckBox( tr( "Ignore unclassified taxa" ), this );
	layout->addWidget( m_ignoreUnclassBtn, row++, col, 1, 3 );
	m_ignoreUnclassBtn->setChecked( m_ui->getIgnoreUnclassified() );

	m_ignoreEnvSampBtn = new QCheckBox( tr( "Ignore environmental samples" ), this );
	layout->addWidget( m_ignoreEnvSampBtn, row++, col, 1, 3 );
	m_ignoreEnvSampBtn->setChecked( m_ui->getIgnoreEnvSamp() );

	layout->setColumnStretch( 0, 100 );
	layout->setRowStretch( row, 100 );

	row++;

	QHBoxLayout	*btnLayout = new QHBoxLayout;

	layout->addLayout( btnLayout, row, 0, 1, 4 );

	btnLayout->setMargin( 0 );
	btnLayout->addStretch( 100 );

	btn = new QPushButton( tr( "Ok" ), this );
	connect( btn, SIGNAL(clicked()), this, SLOT(accept()) );
	btnLayout->addWidget( btn );

	btn = new QPushButton( tr( "Cancel" ), this );
	connect( btn, SIGNAL(clicked()), this, SLOT(reject()) );
	btnLayout->addWidget( btn );
}
